#include <bits/stdc++.h>

#define endl '\n'

using namespace std;

typedef long long LL;

int T, n, m, k;
LL ans;

int a[510][510];

int get_sum(int i, int j, int u, int v)
{
	return a[i][j] - a[u - 1][j] - a[i][v - 1] + a[u - 1][v - 1];
}

int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	
	cin >> n >> m >> k;
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= m; j ++ )
			cin >> a[i][j], a[i][j] += a[i][j - 1] + a[i - 1][j] - a[i - 1][j - 1];
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= m; j ++ )
			for (int u = i; u <= n; u ++ )
			{
				int l = j - 1, r = m;
				
				while (l < r)
				{
					int mid = l + r + 1 >> 1;
					if (get_sum(u, mid, i, j) <= k) l = mid;
					else r = mid - 1;
				}
				ans += r - j + 1;
//				cout << i << "==" << j << "===" << u << "==" << r << "==" << ans << endl;
			}
			
	cout << ans << endl;
				
    return 0;
}